Variant Image Tagging Guide
Overview
When the "Hide unselected variant media" setting is enabled in the Product Media Gallery block, you can now associate multiple images with each variant using a simple alt text tagging system.
How It Works
The gallery will hide images based on two criteria:
- Original Shopify behavior: Hides images that are directly attached to other variants (the single image per variant)
- Enhanced behavior: Hides images tagged for other variants in their alt text
How to Tag Images
Add a tag to the alt text of each image using this format:
variant-{option1}-{option2}-{option3}
Examples
Product with Color and Size variants:
For a "Red" and "Small" variant:
- Alt text:
Red t-shirt front view variant-red-small - Alt text:
Red t-shirt back view variant-red-small - Alt text:
Red t-shirt detail variant-red-small
For a "Blue" and "Large" variant:
- Alt text:
Blue t-shirt front view variant-blue-large - Alt text:
Blue t-shirt back view variant-blue-large
Product with single option (Color only):
For a "Red" variant:
- Alt text:
Product image variant-red
Important Rules
-
Use lowercase and hyphens: Variant tags are automatically converted to lowercase with hyphens (using Liquid's
handleizefilter)- "Red Small" becomes
variant-red-small - "Dark Blue" becomes
variant-dark-blue - "XL" becomes
variant-xl
- "Red Small" becomes
-
Order matters: Options must be in the same order as defined in Shopify:
- If your options are "Color" then "Size", use
variant-red-small(notvariant-small-red)
- If your options are "Color" then "Size", use
-
Tag placement: The
variant-tag can appear anywhere in the alt text- ✅
Product name variant-red-small lifestyle shot - ✅
variant-red-small - Product detail view - ✅
Beautiful red shirt variant-red-small on model
- ✅
-
Untagged images: Images without a
variant-tag in their alt text will show for ALL variants
Setting Up in Shopify Admin
- Go to Products > Select your product
- Scroll to Media section
- For each image, click the image options and select Edit
- In the Alt text field, add your variant tag
- Click Done
Example Setup for a T-Shirt
Let's say you have a t-shirt with these variants:
- Red / Small
- Red / Large
- Blue / Small
- Blue / Large
And 8 images total (4 images per color):
Red variant images:
Alt text: "Red t-shirt front view variant-red-small"
Alt text: "Red t-shirt back view variant-red-small"
Alt text: "Red t-shirt on model variant-red-small"
Alt text: "Red t-shirt detail close-up variant-red-small"
Blue variant images:
Alt text: "Blue t-shirt front view variant-blue-small"
Alt text: "Blue t-shirt back view variant-blue-small"
Alt text: "Blue t-shirt on model variant-blue-small"
Alt text: "Blue t-shirt detail close-up variant-blue-small"
Result: When a customer selects "Red / Small", they'll only see the 4 red images. When they select "Blue / Small", they'll only see the 4 blue images.
Sharing Images Across Similar Variants
If you want the same images to show for multiple similar variants (e.g., all sizes of the same color), you have two options:
Option 1: Tag with multiple variant combinations
Add multiple variant tags to the alt text:
Alt text: "Red t-shirt detail variant-red-small variant-red-medium variant-red-large"
Option 2: Don't include the option in the tag
If you only want to filter by color (not size), use tags without the size:
Alt text: "Red t-shirt detail variant-red"
⚠️ Warning: This approach requires custom code modifications to the theme and is not currently supported out of the box.
Enabling the Feature
- Go to Theme Customizer
- Navigate to your product template
- Select the Product Media Gallery block
- Enable "Hide unselected variant media"
- (Optional) Enable "Hide untagged images (strict mode)" if you want ONLY tagged images to show
- Save your changes
Setting Options
Hide unselected variant media (Required)
- Enables the variant filtering feature
- Hides images attached to other variants
- Hides images tagged for other variants
Hide untagged images (strict mode) (Optional)
- Only appears when "Hide unselected variant media" is enabled
- When OFF: Untagged images show for all variants (default)
- When ON: Only images with matching variant tags show (strict mode)
Troubleshooting
Images aren't hiding:
- Check that "Hide unselected variant media" is enabled
- Verify alt text tags match the exact variant option names (lowercase with hyphens)
- Confirm option order matches Shopify's option order
Some images show for wrong variants:
- Make sure there are no typos in variant tags
- Check that option names are handleized correctly (spaces → hyphens, lowercase)
Images disappear completely:
- Ensure at least one image is tagged for each variant
- Check that untagged "general" images exist if needed
Technical Details
The system uses Liquid's handleize filter to convert variant option values:
- Converts to lowercase
- Replaces spaces with hyphens
- Removes special characters
Example transformations:
- "Dark Blue" →
dark-blue - "Extra Large" →
extra-large - "Red/Orange" →
red-orange
Best Practices
- Always include descriptive alt text for accessibility, with the variant tag as a suffix
- Use consistent naming across all products
- Tag all variant-specific images to avoid confusion
- Keep some untagged images for general product information that applies to all variants
- Test thoroughly after setting up to ensure correct images show for each variant